package com.jz.netthings.utils;

import java.util.Date;

public class TextUnit {

    public static String StringsToText(String[] v) {
        StringBuilder Temp = new StringBuilder();
        for (int i = 0; i < v.length; i++) {
            if (i > 0) {
                Temp.append(",");
            }
            Temp.append(v[i]);
        }
        return Temp.toString();
    }

    public static String ObjToString(Object v) {
        if (v != null) {
            if ((v instanceof String[])) {
                return StringsToText((String[]) v);
            }
            if ((v instanceof Date)) {
                return DateUnit.toText((Date) v);
            }
            return v.toString();
        }
        return null;
    }

    public static boolean isEmptyValue(Object v) {
        if (v == null) {
            return true;
        }
        if ((v instanceof String)) {
            return ((String) v).length() < 1;
        }
        if ((v instanceof byte[])) {
            return ((byte[]) v).length < 1;
        }
        return false;
    }

    public static boolean StringIsEmpty(String s) {
        return (s == null) || (s.length() < 1);
    }

}
